package com.meiyou.controller;

import javax.servlet.http.HttpServletRequest;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import com.meiyou.pojo.WXUserInfo;
import com.meiyou.service.WeChatService;
import com.meiyou.utils.Msg;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;

@Controller
@Api(value = "微信登录", tags = { "微信登录接口" })

public class WechatController {
	
	@Autowired
	WeChatService wxService;
	@RequestMapping(value="wechatLogin",method=RequestMethod.GET)
	@ApiOperation("微信登录")
	public @ResponseBody Msg wechatLogin(String code,HttpServletRequest req) {
		
		Msg msg = wxService.getWxAuthCode(code,req);
		Msg msg1;
	    
		if(msg!=null) {
			msg1 = msg;
			return msg1;
		}else {
			msg1 = Msg.fail();
			msg1.setMsg("出现异常");
			return msg1;
		}
	}
	
	

}
